<input type="hidden" id="user_rates" name="user_rates" value='<?php echo $user_rates; ?>'>
<input type="hidden" value="60" id="items_per_page_4vh"  name="items_per_page_4vh"/>
<input type="hidden" value="" id="htags" name="htags"/>

<script type="text/javascript">
    /**
    * Callback function that displays the content.
    *
    * Gets called every time the user clicks on a pagination link.
    *
    * @param {int}page_index New Page index
    * @param {jQuery} jq the container with the pagination links as a jQuery object
    */
    function vhPageSelectCallback(page_index, jq){
        // Get number of elements per pagionation page from form
        var items_per_page = $('#items_per_page_4vh').val();
        var newtbl1 = '';
        var newtbl2 = '';
        var newtbl3 = '';

        var json_mems = jQuery("#user_rates").val();
        var mems = jQuery.parseJSON(json_mems);

        var max_elem = Math.min((page_index+1) * items_per_page, mems.length);
        // Iterate through a selection of the content and build an HTML string
        var ii = 1;
        for(var i=page_index*items_per_page;i<max_elem;i++)
        {
            if(i<=page_index*items_per_page+19){
                newtbl1 += '<tr>';
                newtbl1 += '<td>'+ (i+1) +'.&nbsp;</td>';
                newtbl1 += '<td>'+ mems[i].Subject.subject +'</td>';
                newtbl1 += '<td>'+ mems[i].SubjectRate.rating +'</td>';
                newtbl1 += '</tr>';
            }else if(i<=page_index*items_per_page+39){
                newtbl2 += '<tr>';
                newtbl2 += '<td>'+ (i+1) +'.&nbsp;</td>';
                newtbl2 += '<td>'+ mems[i].Subject.subject +'</td>';
                newtbl2 += '<td>'+ mems[i].SubjectRate.rating +'</td>';
                newtbl2 += '</tr>';
            }else{
                newtbl3 += '<tr>';
                newtbl3 += '<td>'+ (i+1) +'.&nbsp;</td>';
                newtbl3 += '<td>'+ mems[i].Subject.subject +'</td>';
                newtbl3 += '<td>'+ mems[i].SubjectRate.rating +'</td>';
                newtbl3 += '</tr>';
            }
            ii++;
        }
        // Replace old content with new content        
        jQuery('#r_tbl_vh3').html(newtbl3);
        jQuery('#r_tbl_vh2').html(newtbl2);
        jQuery('#r_tbl_vh1').html(newtbl1);

        // Prevent click eventpropagation
        return false;
    }
    
    // When document has loaded, initialize pagination and form
    jQuery(document).ready(function(){
            // Create pagination element with options
            var optInit = {callback: vhPageSelectCallback};
            optInit.items_per_page = jQuery('#items_per_page_4vh').val();
            optInit.num_display_entries = 10;
            optInit.num_edge_entries = 2;
            optInit.prev_text = "Prev";
            optInit.next_text = "Next";
            var data = jQuery('#user_rates').val();
            var mems = jQuery.parseJSON(data);
//            alert(mems[0].Subject);
            jQuery("#pagination4vh").pagination(mems.length, optInit);
    });
</script>

<div class=framebox_quick_profile style="padding-bottom:20px;border-bottom:solid 5px #00aedb;">
    <dl>
        <?php                                    
            $thumbnail = $this->PhpThumb->generate(
                array(
                    'save_path' => WWW_ROOT . 'img/uploads/Moderators/thumbs',
                    // Where to save the thumbnail. (Make sure it is writable by the web server)

                    'display_path' => 'uploads/Moderators/thumbs',
                    // The web accessible path to the directory that the thumbnail lives in after its created.

                    'error_image_path' => 'img/error.jpg',
                    // The default image to display if something goes wrong while generating a thumbnail. 

                    'src' => WWW_ROOT . "img/uploads/Moderators/" . $access->getmy('image'),
                    // The source image to be converted into a thumbnail.
                    // From here on out, you can pass any standard phpThumb parameters

                    'w' => 165,
                    'h' => 165,
                    'q' => 100,
                    'zc' => 1
                    //'fltr'=>array('ric|4|4')
                )
            );

        ?>        
        <dt><?php echo $this->Html->image($thumbnail['src'], array('width' => $thumbnail['w'], 'height' => $thumbnail['h'])); ?></dt>
        <dd>
            <h2><?php echo $get_user_infor['firstname']. ' ' . $get_user_infor['lastname']; ?></h2>
            <table>
                <tr>
                    <td colspan="2" width="30%">Ranks <span blue class=medium>#<?php echo $rank['rank'] ?></span> in points</td>
                    <td width="70%">level: <span blue class=large><?php echo $level ?></span></td>
                </tr>
                <tr>
                    <td width="30%">has <span blue><?php echo $points ?></span> points</td>
                    <td width="30%">rated <span blue><?php echo $subjects_rated ?></span> subjects</td>
                    <td width="30%">added <span blue><?php echo $subject_added ?></span> subjects</td>
                </tr>
                <tr>
                    <td colspan="3">Rating the universe since: March 14, 2011</td>
                </tr>
            </table>
        </dd>
    </dl>
</div>

<div clear=clear></div>

<!-- VOTING HISTORY -->
<div id=voting_history class='vh_results'>
    <div class='col1 results_box' id="r_box_vh1">
        <table width="100%" id="r_tbl_vh1">

        </table>
    </div>

    <div class='col1 results_box' id="r_box_vh2">
        <table width="100%" id="r_tbl_vh2">

        </table>
    </div>

    <div class='col1 results_box' id="r_box_vh3">
        <table width="100%" id="r_tbl_vh3">

        </table>
    </div> 

    <br style="clear:both;" />
    <div id="pagination4vh" class="pagination col2 right"/>
</div>